function goContactUs(id ,suffix) {
    if(suffix == undefined) {
        suffix = "";
    }
    console.info("id:" + id);
    var contactUs = document.querySelector("#contact-us"+suffix);
    var options = contactUs.getElementsByTagName("option");
    for (var i = 0; i < options.length; i++) {
        options[i].removeAttribute("selected");
    }
    document.getElementById(id+suffix).setAttribute("selected", "true");
    contactUs.scrollIntoView({
        behavior: "auto",
        block: "start"
    });
}

$(".item-title").mouseover(function () {

    var index = getIndex(this);

    // 改变样式
    var currObj = $(this).find("div:first")

    $(this).removeClass("black").addClass("blue");
    var broDoms = $(this).siblings();
    var needCssOther;
    var currCssOther;
    var broDomDiv;
    $(broDoms).each(function (i, e) {
        if ($(e).hasClass("blue")) {
            $(e).removeClass("blue").addClass("black");
        }
        broDomDiv = $(e).find("div:first");
        currCssOther = $(e).find("div:first").attr("class");
        if (currCssOther.indexOf("-active") > 0) {
            needCssOther = currCssOther.substring(0, currCssOther.length - "-active".length);
            $(broDomDiv).removeClass(currCssOther).addClass(needCssOther);
        }
    });

    var currCss = $(currObj).attr("class");
    var needCss;
    if (currCss.indexOf("-active") < 0) {
        needCss = currCss + "-active";
        $(currObj).removeClass(currCss).addClass(needCss);
    }

    $(".content-item").each(function (i, e) {
        if (i == index) {
            if ($(e).hasClass("content-disable")) {
                $(e).removeClass("content-disable").addClass("content-enable");
            }
        } else {
            if ($(e).hasClass("content-enable")) {
                $(e).removeClass("content-enable").addClass("content-disable");
            }
        }
    });
});

function getIndex(obj) {
    return $(obj).index();
}

$("input").blur(function () {
    var suffix = $(this).data("suffix");
    console.info("suffix:"+suffix);
    checkForm(suffix);
});

function checkForm(suffix) {
    if(suffix == undefined) {
        suffix = "";
    }

    var email = $("#email"+suffix).val();
    var name = $("#name"+suffix).val();
    var tel = $("#tel"+suffix).val();
    var target = $("#target"+suffix).val();

    if (email != "" && name != "" && tel != "" && target != "") {
        $("#saveFormBtn"+suffix).show("fast",function () {
            $(this).css("display", "block");
        });
    }
}

function doSave(suffix) {

    if(suffix == undefined ){
        suffix = "";
    }

    $.ajax({
        type: "POST",
        dataType: "json",
        url: "/home/save",
        data: $("#saveForm" +suffix).serialize(),
        success: function (result) {
            console.info(result);
            if (result.code == '200') {
                $("#success" + suffix).show("fast",function () {
                    $(this).css("display", "block");
                });
                $("#saveForm" + suffix).hide("fast", function () {
                    $(this).css("display", "none");
                });
            }
        },
        error: function () {
        }
    })

    return false;
}

// $("a").click(function () {
//     var target = $(this).data("target");
//     var targetElement = document.getElementById(target);
//     targetElement.scrollIntoView({
//         behavior: "auto",
//         block: "start"
//     });
//
// });
$(".wx-logo").mouseover(function () {
    $(".wx-code").show();
});

$(".wx-logo").mouseout(function () {
    $(".wx-code").hide();
})

$("#geng").on("click",function(){
    $(".list").toggle();
})

$("#spa").on("click",function(){
    $("#i").toggle();
})